package myservlet;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.alibaba.fastjson.JSONException;

import java.sql.*;
import java.util.Random;



/**
 * Servlet implementation class myservlet
 */
@WebServlet("/myservlet")
public class myservlet extends HttpServlet {
	//take_json tj=new take_json();
	server_main ser=new server_main();
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public myservlet() {//构造函数
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		//mysql m=new mysql();
		//response.getWriter().append("Served at: ").append(request.getContextPath()).append(m.in_user_pass("admin", "admin")?"true":"false");
		doPost(request,response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		response.setContentType("text/json;charset=utf-8");//设定接受数据的格式为json
		response.setCharacterEncoding("utf-8");
		PrintWriter out = response.getWriter();
		//out.print(tj.json(request));
		
		

		//mysqls ms=new mysqls();
		//String sql="select "+ms.u_username+","+ms.u_password+" from "+ms.user_table+";";
		//out.print(ms.test(sql));
		out.print(ser.get(request));
		
		out.flush();
		out.close();
	}
	

}
